Repository navigation
fix(expression): handle -NaN upper bounds in inclusive and strict metrics evaluator - #1186
Open
deepaknettem wants to merge 1 commit into
Open
deepaknettem wants to merge 1 commit into
deepaknettem wants to merge 1 commit into
Conversation
zhjwpku
reviewed
Nov 28, 2026
| if (upper_it != data_file_.upper_bounds.cend()) { | ||
| ICEBERG_ASSIGN_OR_RAISE(auto upper, ParseBound(expr, upper_it->second)); | ||
| if (upper.IsNaN()) { | ||
| return kRowsMightNotMatch; |
Member
There was a problem hiding this comment.
Strict NOT IN discards a usable lower bound. With lower = 10, x NOT IN (1, 2) must match every row, correct me if I'm wrong :-)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Writers like ORC can record NaN for both lower and upper bounds when the first value in a float/double column is NaN, even if finite values are present later in the file. When that value is -NaN (for example, 0.0 / 0.0 on x86-64), pruning is incorrect.
I added unit tests setting upper_bounds to -NaN to confirm my suspicion and saw them fail.
Java implementation checks isNaN(lower) only because Float.compare / Double.compare collapses -NaN to +NaN at the time of comparison, so it doesn't need to handle this case.
I saw the PyIceberg implementation, and it is also doing an explicit check on upper_bounds with a comment to that effect (visitors.py#L1415-L1417).
In existing implementation, -NaN upper bound causes both upper < lit and upper <= lit evaluate true, so without an explicit check for -NaN,
References:
Fix
upper->IsNaN()in InclusiveMetricsEvaluator (Gt, GtEq, Eq, In) and returnkRowsMightMatch.upper.IsNaN()in StrictMetricsEvaluator (Lt, LtEq, NotEq, NotIn) and returnkRowsMightNotMatch.Tests